Private Sub SetCaptions(recFormal As Recordset, strFormality As String, strFormName As String)

   Dim frmF As Form
   Dim ctlC As Control
   Dim strControlName As String
   Dim intControlType As Integer
   
   'Open the form, hidden, in Design View
   DoCmd.OpenForm strFormName, acDesign, , , , acHidden
   
   'Add the form caption
   Set frmF = Forms(strFormName)
   With recFormal
      .Seek "=", strFormName, strFormName
      
      'Add or update the form in the font weight table
      If .NoMatch Or IsNull(.Fields(strFormality)) Then
         frmF.Caption = ""
      Else
         frmF.Caption = .Fields(strFormality)
      End If
      
      'Loop through the controls
      For Each ctlC In frmF.Controls
      
         'We are only interested in the command buttons
         intControlType = ctlC.ControlType
         If intControlType = acCommandButton Then
            'Find the control in the tblFormality table
            strControlName = ctlC.Name
            .Seek "=", strFormName, strControlName
            
            'Add or update the control in the tblFormality table
            If .NoMatch Or IsNull(.Fields(strFormality)) Then
               ctlC.Caption = ""
            Else
               ctlC.Caption = .Fields(strFormality)
            End If
         End If
      Next
   End With
   
   'Close the form and save it
   DoCmd.Close acForm, strFormName, acSaveYes
   
End Sub
